#!/usr/bin/env drgn

from drgn.helpers.linux.percpu import per_cpu
from drgn.helpers.linux.llist import llist_for_each
from drgn.helpers.linux.cpumask import for_each_online_cpu,cpumask_to_cpulist
from drgn import Object,cast


def print_ccd():
    cpus = set()
    for c in for_each_online_cpu():
        mc = per_cpu(prog['sd_llc'], c)

        span = cast('struct cpumask*', mc.span[0].address_of_())
        ret = cpumask_to_cpulist(span)
        if ret not in cpus:
            cpus.add(ret)

    print('All ccd cpu list:')
    for l in cpus:
        print(l)

print_ccd()

